package lei.o_序列化;

import lei.o_序列化.Person;

import java.io.*;

public class DeserializationExample {
    public static void deserializeObject() {
        try (ObjectInputStream ois = new ObjectInputStream(
                new FileInputStream("person.txt"))) {

            // 从文件反序列化对象
            Person person = (Person) ois.readObject();
            System.out.println("对象已从文件反序列化: person.txt");
            System.out.println("反序列化的对象: " + person);

        } catch (IOException | ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
}
